<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue 测试实例 - 菜鸟教程(runoob.com)</title>
<script src="https://cdn.staticfile.org/vue/3.2.36/vue.global.min.js"></script>
</head>
<body>
<div id="app">
    <p>页面载入时，input自动获取焦点： </p>
    <input v-focus>   
</div>

<script>
  const app = {
   data() {
      return {
        // num:1
      }
   },
   directives: {
      focus: {
         mounted(el) {
            el.focus()
          // console.log("提示：",this.$data.num)
         }
      }
   }
} 
Vue.createApp(app).mount('#app')
</script>
</body>
</html>
